package com.fdb.efp.nls.common.util.solt;

import java.util.ArrayList;
import java.util.List;

/**
 * 需求编号:2019D08--
 * 问题编号:
 * 开发人员: caoxin
 * 创建日期:2019/12/6
 * 功能描述:
 * 修改日期:2019/12/6
 * 修改描述:
 */
public abstract class AbstractSoltInfo<T> {

    protected List<AbstractSoltInfo> soltInfos = new ArrayList<>();
    // 产品ID
    protected String prdId;
    // 插槽代码
    protected String soltCode;
    // 插槽名称
    protected String soltName;
    // 插槽服务类
    protected String soltService;
    // 插槽阶段类
    protected String soltStage;
    // 插槽顺序
    protected int soltOrder;

    public String getPrdId() {
        return prdId;
    }

    public String getSoltCode() {
        return soltCode;
    }

    public String getSoltName() {
        return soltName;
    }

    public String getSoltService() {
        return soltService;
    }

    public String getSoltStage() {
        return soltStage;
    }

    public int getSoltOrder() {
        return soltOrder;
    }

    protected AbstractSoltInfo() {

    }

    protected AbstractSoltInfo(String prdId, String soltCode, String soltName, String soltService, String soltStage, int soltOrder) {
        this.prdId = prdId;
        this.soltCode = soltCode;
        this.soltName = soltName;
        this.soltService = soltService;
        this.soltStage = soltStage;
        this.soltOrder = soltOrder;
    }

    public abstract boolean check(String prdId, String soltCode, String soltName, String soltService, String soltStage, int soltOrder);

    public boolean checkSoltInfo(String prdId, String soltCode, String soltName, String soltService, String soltStage, int soltOrder) {
        return parse(prdId, soltCode).validateSoltService(soltName, soltService, soltStage, soltOrder);
    }
    public List<AbstractSoltInfo> getSoltInfos() {
        return soltInfos;
    }
    public AbstractSoltInfo parse(String prdId, String soltCode) {
        return getSoltInfos().stream().filter(value -> value.getPrdId().equals(prdId) && value.getSoltCode().equals(soltCode))
                .findFirst().orElseThrow(RuntimeException::new);

    }



    public boolean validateSoltService(String soltName, String soltService, String soltStage, int soltOrder) {
        return getSoltName().equals(soltName) && getSoltService().equals(soltService) && getSoltStage().equals(soltStage) && getSoltOrder() == soltOrder;
    }
}
